const fs = require('fs');
const path = require('path');

const dirs = [
  'project-share                     # 项目欢迎页',
  'project-login                     # 项目登录页',
  'project-register                  # 项目注册页',
  'project-index                     # 内容页',
  'project-members                   # 成员页',
  'project-file-preview              # 文件预览页',
  'project-check-detail              # 确认批次详情页',
  'project-check-task                # 确认批次-任务',
  'project-check-file                # 确认批次-任务',
  'project-check-log                 # 确认批次-日志',
  'file-share                        # 文件欢迎页',
  'file-login                        # 文件登录页',
  'file-register                     # 文件注册页',
  'file-index                        # 内容页',
  'check-share                       # 确认欢迎页',
  'check-login                       # 确认登录页',
  'check-register                    # 确认注册页',
  'check-index                       # 内容页',
]


dirs.forEach(info => {
 
  const [name, desc] = info.split(/\s+# /);

  const dir = `./src/pages/${name}`

  const indexTs = `import React, { Component } from "react";
  import { View, Button, Text } from "@tarojs/components";
  import { observer, inject } from "mobx-react";
  
  import "./index.scss";
  
  type PageStateProps = {
    store: {
      rootStore: {
        counter: number;
        increment: Function;
        decrement: Function;
        incrementAsync: Function;
      };
    };
  };
  
  interface Index {
    props: PageStateProps;
  }
  
  @inject("store")
  @observer
  class Index extends Component {
    componentWillMount() {}
  
    componentDidMount() {}
  
    componentWillUnmount() {}
  
    componentDidShow() {}
  
    componentDidHide() {}
  
    render() {
      const {
        rootStore: { counter },
      } = this.props.store;
      return <View className="${name}">${desc}</View>;
    }
  }
  
  export default Index;`

    fs.writeFileSync(`${dir}/index.tsx`, indexTs)

}) 
